#!/usr/bin/env python
# $Id: test2-49.py 5353b6f0f8b5 2012/12/04 07:38:16 pgurumur $
# Copyright (c) 2012 Prabhu Gurumurthy <pgurumur@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

__version__  = "$Revision: 5353b6f0f8b5 $"
__author__   = "$Author: pgurumur $"
__modified__ = "$Date: 2012-12-04 07:38:16Z $"

import os
import sys
import jinja2
import time

"""
>>> from jinja2 import Template
>>> >>> template = Template('Hello {{ name }}!')
>>> >>> >>> template.render(name='John Doe')
>>> >>> >>> u'Hello John Doe!'
>>> >>> >>>
>>> >>> >>>
"""

if __name__ == "__main__":
   language = sys.argv[1]
   filename = sys.argv[2]
   year = time.strftime("%Y", time.localtime())
   date = time.strftime("%A %B %d, %Y @ %T %Z", time.localtime())

   with open(filename, "w") as fh:
      env = jinja2.Environment(loader = jinja2.FileSystemLoader(os.getcwd()))
      template = env.get_template('script.j2')
      print(template.render(interpreter = language, year = year, date = date, 
            name = filename, module = 0, version = 0))

